package com.example.demo;

import com.example.demo.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/response")
//可以输出页面, 记得加/g
@Controller


public class ResponseController {
    @RequestMapping("/returnHtmlPage")
    public String returnHtmlPage(){
        return "/test.html";
    }

    @ResponseBody
    @RequestMapping("/returnData")
    public String returnHtmlPage1(){
        return "5634534io5u34";
    }

    @ResponseBody
    @RequestMapping("/returnHtml")
    public String returnHtml(){
        return "<h1>hello,html </h1>";
    }

    @ResponseBody
    @RequestMapping("/returnJson")
    public User returnJson(){
        User user = new User();
        user.setName("豆迪");
        user.setAge(20);
        return user;
    }
}
